package luogu;

import java.util.Scanner;

public class P1328 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        int[] m1 = new int[n1];
        int[] m2 = new int[n2];
        for (int i = 0; i < n1; i++) {
            m1[i] = sc.nextInt();
        }
        for (int i = 0; i < n2; i++) {
            m2[i] = sc.nextInt();
        }
        int a;
        int b;
        int r1 = 0;
        int r2 = 0;
        for (int i = 0; i < n; i++) {
            a = m1[i-i/n1*n1];
            b = m2[i-i/n2*n2];
            if (a == b) {
                continue;
            }
            if ((a == 0 && (b == 2 || b == 3)) || (a == 1 && (b == 0 || b == 3)) || (a == 2 &&(b == 1 || b == 4) || (a == 3 && (b == 2 || b == 4)) || (a == 4 && (b == 0 || b == 1)))) {
                r1++;
            }else {
                r2++;
            }
        }
        System.out.println(r1+" "+r2);
    }
}
